package com.example.network_services_twit_begin;

import org.apache.http.entity.SerializableEntity;

import android.os.Bundle;
import android.app.Activity;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class MainActivity extends Activity {

	// search word for twitter results.
	EditText etSearch;
	
	// button for execution
	Button buttonExecute;
	
	// response from twitter with htmlcode.
	EditText etTwitterResponse;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
		etSearch = (EditText) findViewById(R.id.et_search);
		buttonExecute = (Button) findViewById(R.id.button_extecute);
		etTwitterResponse = (EditText) findViewById(R.id.et_twitter_response);
		
		// onclick listener.
		buttonExecute.setOnClickListener( new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// check if search box not empty
				if (etSearch != null && etSearch.length() > 0){
					SearchTask executeTask = new SearchTask(etTwitterResponse);
					executeTask.execute(etSearch.getText() +  "");
				}	
			}
		});
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

}
